LanguageExt.Core

LanguageExt.Core Monads Alternative Value Monads Fin

The Fin monad supports either an Error or an A (success) value. It is functionally exactly the same as Either<Error, A>, it is a convenience type to avoid the generics pain of Either.

To construct a Fin:

Fin<int> ma = Pure(123);
Fin<int> mb = Fail(Error.New("Error!"));

Contents

class Fin <A> Source #

Equivalent of Either<Error, A> Called Fin because it is expected to be used as the concrete result of a computation

Properties

property bool IsSucc Source #

Is the structure in a Success state?

property bool IsFail Source #

Is the structure in a Fail state?

property Fin<A> Empty Source #

Monoid empty

Methods

method Fin<A> Succ (A value) Source #

method Fin<A> Fail (Error error) Source #

method Fin<A> Fail (string error) Source #

method B Match <B> (Func<A, B> Succ, Func<Error, B> Fail) Source #

Invokes the Succ or Fail function depending on the state of the structure

Parameters

type B

Return type

param Succ

Function to invoke if in a Succ state

param Fail

Function to invoke if in a Fail state

returns

The return value of the invoked function

method ReadOnlySpan<Error> FailSpan () Source #

Empty span

method ReadOnlySpan<A> SuccSpan () Source #

Span of right value

method int CompareTo <OrdA> (Fin<A> other) Source #

where OrdA : Ord<A>

Compare this structure to another to find its relative ordering

method bool Equals <EqA> (Fin<A> other) Source #

where EqA : Eq<A>

Equality override

method bool Equals (Fin<A>? other) Source #

Equality override

method bool Equals (object? other) Source #

Equality override

method int GetHashCode <HashA> () Source #

where HashA : Hashable<A>

method int GetHashCode () Source #

method Fin<B> Map <B> (Func<A, B> Succ) Source #

Maps the value in the structure

Parameters

param f

Map function

returns

Mapped structure

method Fin<B> BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail) Source #

Bi-maps the structure

Parameters

returns

Mapped Either

method Fin<B> Bind <B> (Func<A, Fin<B>> f) Source #

Monadic bind

Parameters

type B

Resulting bound value

param f

Bind function

returns

Bound structure

method Fin<B> BiBind <B> (Func<A, Fin<B>> Succ, Func<Error, Fin<B>> Fail) Source #

Bi-bind. Allows mapping of both monad states

method int CompareTo (Fin<A>? other) Source #

method IEnumerator<A> GetEnumerator () Source #

method int CompareTo (object? obj) Source #

method Unit Match (Action<A> Succ, Action<Error> Fail) Source #

method A IfFail (Func<Error, A> Fail) Source #

method A IfFail (A alternative) Source #

method Unit IfFail (Action<Error> Fail) Source #

method Unit IfSucc (Action<A> Succ) Source #

method Unit Iter (Action<A> Succ) Source #

method S Fold <S> (S state, Func<S, A, S> f) Source #

method S BiFold <S> (in S state, Func<S, A, S> Succ, Func<S, Error, S> Fail) Source #

method bool Exists (Func<A, bool> f) Source #

method bool ForAll (Func<A, bool> f) Source #

method K<F, Fin<B>> Traverse <F, B> (Func<A, K<F, B>> f) Source #

where F : Applicative<F>

Map each element of a structure to an action, evaluate these actions from left to right, and collect the results.

Parameters

type F

Applicative functor trait

type B

Bound value (output)

param f
param ta

Traversable structure

method Fin<B> Select <B> (Func<A, B> f) Source #

method Fin<B> Bind <B> (Func<A, K<Fin, B>> f) Source #

method Fin<B> Bind <B> (Func<A, Pure<B>> f) Source #

method Fin<A> Bind (Func<A, Fail<Error>> f) Source #

method Fin<C> SelectMany <B, C> (Func<A, Fin<B>> bind, Func<A, B, C> project) Source #

method Fin<C> SelectMany <B, C> (Func<A, K<Fin, B>> bind, Func<A, B, C> project) Source #

method Fin<C> SelectMany <B, C> (Func<A, Pure<B>> bind, Func<A, B, C> project) Source #

method Fin<Unit> SelectMany (Func<A, Fail<Error>> bind, Func<A, Error, Unit> project) Source #

method Lst<A> ToList () Source #

method Seq<A> ToSeq () Source #

method Arr<A> ToArray () Source #

method Option<A> ToOption () Source #

method Sum<Error, A> ToSum () Source #

method Either<Error, A> ToEither () Source #

method Eff<A> ToEff () Source #

method A ThrowIfFail () Source #

Operators

operator | (Fin<A> left, Fin<A> right) Source #

operator true (Fin<A> ma) Source #

operator false (Fin<A> ma) Source #

operator == (Fin<A> ma, Fin<A> mb) Source #

operator != (Fin<A> ma, Fin<A> mb) Source #

operator < (Fin<A> lhs, A rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator <= (Fin<A> lhs, A rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator > (Fin<A> lhs, A rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator >= (Fin<A> lhs, A rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator < (A lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator <= (A lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator > (A lhs, Fin<A>rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator >= (A lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator < (Fin<A> lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs < rhs

operator <= (Fin<A> lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs <= rhs

operator > (Fin<A> lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs > rhs

operator >= (Fin<A> lhs, Fin<A> rhs) Source #

Comparison operator

Parameters

param lhs

The left hand side of the operation

param rhs

The right hand side of the operation

returns

True if lhs >= rhs

operator == (Fin<A> lhs, Error rhs) Source #

Equality operator override

operator == (Fin<A> lhs, A rhs) Source #

Equality operator override

operator == (A lhs, Fin<A> rhs) Source #

Equality operator override

operator == (Error lhs, Fin<A> rhs) Source #

Equality operator override

operator != (Fin<A> lhs, Error rhs) Source #

Non-equality operator override

operator != (Error lhs, Fin<A> rhs) Source #

Non-equality operator override

operator != (Fin<A> lhs, A rhs) Source #

Equality operator override

operator != (A lhs, Fin<A> rhs) Source #

Equality operator override

class FinExtensions Source #

Extension methods for Fin

Methods

method Fin<A> As <A> (this K<Fin, A> ma) Source #

method Fin<A> ToFin <A> (this Either<Error, A> ma) Source #

Natural transformation from Either to Fin

method Fin<R> Flatten <R> (this Fin<Fin<R>> ma) Source #

Monadic join

method Fin<R> Plus <NUM, R> (this Fin<R> x, Fin<R> y) Source #

where NUM : Arithmetic<R>

Add the bound values of x and y, uses an Add trait to provide the add operation for type A. For example x.Add<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Fin with y added to x

method Fin<R> Subtract <NUM, R> (this Fin<R> x, Fin<R> y) Source #

where NUM : Arithmetic<R>

Find the subtract between the two bound values of x and y, uses a Subtract trait to provide the subtract operation for type A. For example x.Subtract<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Fin with the subtract between x and y

method Fin<R> Product <NUM, R> (this Fin<R> x, Fin<R> y) Source #

where NUM : Arithmetic<R>

Find the product between the two bound values of x and y, uses a Product trait to provide the product operation for type A. For example x.Product<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Fin with the product of x and y

method Fin<R> Divide <NUM, R> (this Fin<R> x, Fin<R> y) Source #

where NUM : Num<R>

Divide the two bound values of x and y, uses a Divide trait to provide the divide operation for type A. For example x.Divide<TDouble,double>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Fin x / y

method Fin<B> Apply <A, B> (this Fin<Func<A, B>> fab, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type FB derived from Applicative of B

method Fin<B> Apply <A, B> (this Func<A, B> fab, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type FB derived from Applicative of B

method Fin<C> Apply <A, B, C> (this Fin<Func<A, B, C>> fabc, Fin<A> fa, Fin<B> fb) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative a to apply

param fb

Applicative b to apply

returns

Applicative of type FC derived from Applicative of C

method Fin<C> Apply <A, B, C> (this Func<A, B, C> fabc, Fin<A> fa, Fin<B> fb) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative a to apply

param fb

Applicative b to apply

returns

Applicative of type FC derived from Applicative of C

method Fin<Func<B, C>> Apply <A, B, C> (this Fin<Func<A, B, C>> fabc, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method Fin<Func<B, C>> Apply <A, B, C> (this Func<A, B, C> fabc, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method Fin<Func<B, C>> Apply <A, B, C> (this Fin<Func<A, Func<B, C>>> fabc, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method Fin<Func<B, C>> Apply <A, B, C> (this Func<A, Func<B, C>> fabc, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method Fin<B> Action <A, B> (this Fin<A> fa, Fin<B> fb) Source #

Evaluate fa, then fb, ignoring the result of fa

Parameters

param fa

Applicative to evaluate first

param fb

Applicative to evaluate second and then return

returns

Applicative of type Fin

method IEnumerable<A> Succs <A> (this IEnumerable<Fin<A>> xs) Source #

Extracts from a list of Fins all the Succ elements.

Parameters

type A

Bound value type

param xs

Sequence of Fins

returns

An enumerable of A

method Seq<A> Succs <A> (this Seq<Fin<A>> xs) Source #

Extracts from a list of Fins all the Succ elements.

Parameters

type A

Bound value type

param xs

Sequence of Fins

returns

An enumerable of A

method IEnumerable<Error> Fails <A> (this IEnumerable<Fin<A>> xs) Source #

Extracts from a list of Fins all the Fail elements.

Bottom values are dropped

Parameters

type A

Bound value type

param xs

Sequence of Fins

returns

An enumerable of Errors

method Seq<Error> Fails <A> (this Seq<Fin<A>> xs) Source #

Extracts from a list of Fins all the Fail elements.

Bottom values are dropped

Parameters

type A

Bound value type

param xs

Sequence of Fins

returns

An enumerable of Errors

method (IEnumerable<Error> Fails, IEnumerable<A> Succs) Partition <A> (this IEnumerable<Fin<A>> xs) Source #

Partitions a list of 'Fin' into two lists. All the Fail elements are extracted, in order, to the first component of the output. Similarly the Succ elements are extracted to the second component of the output.

Bottom values are dropped

Parameters

type A

Bound value type

param xs

Fin list

returns

A tuple containing the an enumerable of Erorr and an enumerable of Succ

method (Seq<Error> Fails, Seq<A> Succs) Partition <A> (this Seq<Fin<A>> xs) Source #

Partitions a list of 'Fin' into two lists. All the Fail elements are extracted, in order, to the first component of the output. Similarly the Succ elements are extracted to the second component of the output.

Bottom values are dropped

Parameters

type A

Bound value type

param xs

Fin list

returns

A tuple containing the an enumerable of Erorr and an enumerable of Succ

class Fin Source #

class Fail <A> Source #

Properties

property Error Error Source #

Value accessor

property bool IsSucc Source #

Is the structure in a Success state?

property bool IsFail Source #

Is the structure in a Fail state?

Methods

method B Match <B> (Func<A, B> Succ, Func<Error, B> Fail) Source #

Invokes the Succ or Fail function depending on the state of the structure

Parameters

type B

Return type

param Succ

Function to invoke if in a Succ state

param Fail

Function to invoke if in a Fail state

returns

The return value of the invoked function

method string ToString () Source #

Show the structure as a string

method int GetHashCode <HashA> () Source #

method ReadOnlySpan<Error> FailSpan () Source #

Empty span

method ReadOnlySpan<A> SuccSpan () Source #

Span of right value

method int CompareTo <OrdA> (Fin<A> other) Source #

Compare this structure to another to find its relative ordering

method bool Equals <EqA> (Fin<A> other) Source #

Equality override

method Fin<B> Map <B> (Func<A, B> Succ) Source #

Maps the value in the structure

Parameters

param f

Map function

returns

Mapped structure

method Fin<B> BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail) Source #

Bi-maps the structure

Parameters

returns

Mapped Either

method Fin<B> Bind <B> (Func<A, Fin<B>> f) Source #

Monadic bind

Parameters

type B

Resulting bound value

param f

Bind function

returns

Bound structure

method Fin<B> BiBind <B> ( Func<A, Fin<B>> Succ, Func<Error, Fin<B>> Fail) Source #

Bi-bind. Allows mapping of both monad states

method void Deconstruct (out Error value) Source #

class FinGuardExtensions Source #

Methods

method Fin<Unit> ToFin (this Guard<Error, Unit> ma) Source #

method Fin<B> SelectMany <B> (this Guard<Error, Unit> ma, Func<Unit, Fin<B>> f) Source #

method Fin<C> SelectMany <B, C> (this Guard<Error, Unit> ma, Func<Unit, Fin<B>> bind, Func<Unit, B, C> project) Source #

method Fin<Unit> SelectMany <A> (this Fin<A> ma, Func<A, Guard<Error, Unit>> f) Source #

method Fin<C> SelectMany <A, C> (this Fin<A> ma, Func<A, Guard<Error, Unit>> bind, Func<A, Unit, C> project) Source #

class Fin Source #

class Prelude Source #

Methods

method Fin<R> flatten <R> (Fin<Fin<R>> ma) Source #

Monadic join

method Fin<R> plus <NUM, R> (Fin<R> x, Fin<R> y) Source #

where NUM : Arithmetic<R>

Add the bound values of x and y, uses an Add trait to provide the add operation for type A. For example x.Add<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Fin with y added to x

method Fin<R> subtract <NUM, R> (Fin<R> x, Fin<R> y) Source #

where NUM : Arithmetic<R>

Find the subtract between the two bound values of x and y, uses a Subtract trait to provide the subtract operation for type A. For example x.Subtract<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Fin with the subtract between x and y

method Fin<R> product <NUM, R> (Fin<R> x, Fin<R> y) Source #

where NUM : Arithmetic<R>

Find the product between the two bound values of x and y, uses a Product trait to provide the product operation for type A. For example x.Product<TInteger,int>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Fin with the product of x and y

method Fin<R> divide <NUM, R> (Fin<R> x, Fin<R> y) Source #

where NUM : Num<R>

Divide the two bound values of x and y, uses a Divide trait to provide the divide operation for type A. For example x.Divide<TDouble,double>(y)

Parameters

type NUM

Num of A

type A

Bound value type

param x

Left hand side of the operation

param y

Right hand side of the operation

returns

Fin x / y

method Fin<B> apply <A, B> (Fin<Func<A, B>> fab, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type FB derived from Applicative of B

method Fin<B> apply <A, B> (Func<A, B> fab, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type FB derived from Applicative of B

method Fin<C> apply <A, B, C> (Fin<Func<A, B, C>> fabc, Fin<A> fa, Fin<B> fb) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative a to apply

param fb

Applicative b to apply

returns

Applicative of type FC derived from Applicative of C

method Fin<C> apply <A, B, C> (Func<A, B, C> fabc, Fin<A> fa, Fin<B> fb) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative a to apply

param fb

Applicative b to apply

returns

Applicative of type FC derived from Applicative of C

method Fin<Func<B, C>> apply <A, B, C> (Fin<Func<A, B, C>> fabc, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method Fin<Func<B, C>> apply <A, B, C> (Func<A, B, C> fabc, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method Fin<Func<B, C>> apply <A, B, C> (Fin<Func<A, Func<B, C>>> fabc, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method Fin<Func<B, C>> apply <A, B, C> (Func<A, Func<B, C>> fabc, Fin<A> fa) Source #

Apply

Parameters

param fab

Function to apply the applicative to

param fa

Applicative to apply

returns

Applicative of type f(b -> c) derived from Applicative of Func<B, C>

method Fin<B> action <A, B> (Fin<A> fa, Fin<B> fb) Source #

Evaluate fa, then fb, ignoring the result of fa

Parameters

param fa

Applicative to evaluate first

param fb

Applicative to evaluate second and then return

returns

Applicative of type Fin

method bool isSucc <A> (Fin<A> value) Source #

Returns the state of the Fin provided

Parameters

type A

Bound value type

param value

Either to check

returns

True if the Fin is in a Succ state

method bool isFail <A> (Fin<A> value) Source #

Returns the state of the Fin provided

Parameters

type A

Bound value type

param value

Either to check

returns

True if the Fin is in an Error state

method Fin<A> FinSucc <A> (A value) Source #

Fin constructor Constructs a Fin in a success state

Parameters

type A

Bound value type

param value

Success value

returns

A new Fin instance

method Fin<A> FinFail <A> (Error value) Source #

Fin constructor Constructs a Fin in a failure state

Parameters

type A

Bound value type

param value

Failure value

returns

A new Fin instance

method A ifFail <A> (Fin<A> ma, Func<Error, A> Fail) Source #

Executes the Fail function if the Fin is in a failure state. Returns the bound value if the Fin is in a success state.

Parameters

type A

Bound value type

param Fail

Function to generate a Fail value if in the failure state

returns

Returns an unwrapped bound value

method A ifFail <A> (Fin<A> ma, A alternative) Source #

Returns the alternative if the Fin is in a failure state. Returns the bound value if the Fin is in a success state.

Parameters

type A

Bound value type

param alternative

Value to return if in the failure state

returns

Returns an unwrapped value

method Unit ifFail <A> (Fin<A> ma, Action<Error> Left) Source #

Executes the Fail action if the Fin is in a failure state.

Parameters

param Fail

Function to generate a value if in the failure state

returns

Returns an unwrapped value

method Unit ifSucc <A> (Fin<A> ma, Action<A> Succ) Source #

Invokes the Succ action if the Fin is in a success state, otherwise does nothing

Parameters

param Succ

Action to invoke

returns

Unit

method B match <A, B> (Fin<A> ma, Func<A, B> Succ, Func<Error, B> Fail) Source #

Invokes the Succ or Fail function depending on the state of the Fin provided

Parameters

type A

Bound value type

type B

Return type

param ma

Fin to match

param Succ

Function to invoke if in a Succ state

param Fail

Function to invoke if in a Fail state

returns

The return value of the invoked function

method Unit match <A> (Fin<A> ma, Action<A> Succ, Action<Error> Fail) Source #

Invokes the Succ or Fail action depending on the state of the Fin provided

Parameters

type A

Bound value type

param ma

Fin to match

param Succ

Action to invoke if in a Succ state

param Fail

Action to invoke if in a Fail state

returns

Unit

method S bifold <S, A> (Fin<A> ma, S state, Func<S, A, S> Right, Func<S, Error, S> Left) Source #

Fin types are like lists of 0 or 1 items, and therefore follow the same rules when folding.

In the case of lists, 'Fold', when applied to a binary operator, a starting value(typically the left-identity of the operator), and a list, reduces the list using the binary operator, from left to right:

Parameters

type S

Aggregate state type

type A

Bound value type

param state

Initial state

param Right

Folder function, applied if Either is in a Succ state

param Left

Folder function, applied if Either is in a Fail state

returns

The aggregate state

method bool forall <A> (Fin<A> ma, Func<A, bool> pred) Source #

Invokes a predicate on the value of the Fin if it's in the Succ state

Parameters

type A

Bound value type

param ma

Fin to extract the value from

param pred

Predicate

returns

True if the Fin is in a Fail state. True if the Fin is in a Right state and the predicate returns True. False otherwise.

method bool exists <A> (Fin<A> ma, Func<A, bool> pred) Source #

Invokes a predicate on the value of the Fin if it's in the Succ state

Parameters

type A

Bound value type

param ma

Fin to extract the value from

param pred

Predicate

returns

True if the Fin is in a Succ state and the predicate returns True. False otherwise.

method Fin<B> map <A, B> (Fin<A> ma, Func<A, B> f) Source #

Maps the value in the Either if it's in a Right state

Parameters

type A

Bound value type

type B

Mapped bound value type

param ma

Either to map

param f

Map function

returns

Mapped Either

method Fin<B> bimap <A, B> (Fin<A> ma, Func<A, B> Succ, Func<Error, Error> Fail) Source #

Bi-maps the value in the Fin

Parameters

type A

Bound value type

type B

Mapped value type if in Succ state

param ma

Fin to map

param Succ

Success state map function

param Fail

Failure state map function

returns

Bi-mapped Fin

method Fin<B> bind <A, B> (Fin<A> ma, Func<A, Fin<B>> f) Source #

method IEnumerable<B> Match <A, B> (this IEnumerable<Fin<A>> xs, Func<A, B> Succ, Func<Error, B> Fail ) Source #

Match over a sequence of Fins

Parameters

type A

Bound values type

type B

Mapped bound values type

param xs

Sequence to match over

param Succ

Success state match function

param Fail

Failure state match function

returns

Sequence of mapped values

method IEnumerable<B> match <A, B> (IEnumerable<Fin<A>> xs, Func<A, B> Succ, Func<Error, B> Fail) Source #

Match over a sequence of Fins

Bottom values are dropped

Parameters

type A

Bound values type

type B

Mapped bound values type

param xs

Sequence to match over

param Succ

Success state match function

param Fail

Failure state match function

returns

Sequence of mapped values

method IEnumerable<A> succs <A> (IEnumerable<Fin<A>> xs) Source #

Extracts from a list of Fins all the Succ elements.

Parameters

type A

Bound value type

param xs

Sequence of Fins

returns

An enumerable of A

method Seq<A> succs <A> (Seq<Fin<A>> xs) Source #

Extracts from a list of Fins all the Succ elements.

Parameters

type A

Bound value type

param xs

Sequence of Fins

returns

An enumerable of A

method IEnumerable<Error> fails <A> (IEnumerable<Fin<A>> xs) Source #

Extracts from a list of Fins all the Fail elements.

Bottom values are dropped

Parameters

type A

Bound value type

param xs

Sequence of Fins

returns

An enumerable of Errors

method Seq<Error> fails <A> (Seq<Fin<A>> xs) Source #

Extracts from a list of Fins all the Fail elements.

Bottom values are dropped

Parameters

type A

Bound value type

param xs

Sequence of Fins

returns

An enumerable of Errors

method (IEnumerable<Error> Fails, IEnumerable<A> Succs) partition <A> (IEnumerable<Fin<A>> xs) Source #

Partitions a list of 'Fin' into two lists. All the Fail elements are extracted, in order, to the first component of the output. Similarly the Succ elements are extracted to the second component of the output.

Bottom values are dropped

Parameters

type A

Bound value type

param xs

Fin list

returns

A tuple containing the an enumerable of Erorr and an enumerable of Succ

method (Seq<Error> Fails, Seq<A> Succs) partition <A> (Seq<Fin<A>> xs) Source #

Partitions a list of 'Fin' into two lists. All the Fail elements are extracted, in order, to the first component of the output. Similarly the Succ elements are extracted to the second component of the output.

Bottom values are dropped

Parameters

type A

Bound value type

param xs

Fin list

returns

A tuple containing the an enumerable of Erorr and an enumerable of Succ

class Fin Source #

class Succ <A> Source #

Properties

property A Value Source #

Value accessor

property bool IsSucc Source #

Is the structure in a Success state?

property bool IsFail Source #

Is the structure in a Fail state?

Methods

method B Match <B> (Func<A, B> Succ, Func<Error, B> Fail) Source #

Invokes the Succ or Fail function depending on the state of the structure

Parameters

type B

Return type

param Succ

Function to invoke if in a Succ state

param Fail

Function to invoke if in a Fail state

returns

The return value of the invoked function

method string ToString () Source #

Show the structure as a string

method int GetHashCode <HashA> () Source #

Get a hash code for the structure

method ReadOnlySpan<Error> FailSpan () Source #

Empty span

method ReadOnlySpan<A> SuccSpan () Source #

Span of right value

method int CompareTo <OrdA> (Fin<A>? other) Source #

Compare this structure to another to find its relative ordering

method bool Equals <EqA> (Fin<A> other) Source #

Equality override

method Fin<B> Map <B> (Func<A, B> Succ) Source #

Maps the value in the structure

Parameters

param f

Map function

returns

Mapped structure

method Fin<B> BiMap <B> (Func<A, B> Succ, Func<Error, Error> Fail) Source #

Bi-maps the structure

Parameters

returns

Mapped Either

method Fin<B> Bind <B> (Func<A, Fin<B>> f) Source #

Monadic bind

Parameters

type B

Resulting bound value

param f

Bind function

returns

Bound structure

method Fin<B> BiBind <B> ( Func<A, Fin<B>> Succ, Func<Error, Fin<B>> Fail) Source #

Bi-bind. Allows mapping of both monad states

method void Deconstruct (out A value) Source #